﻿module Sustainalytics.Governance {
    export class GovernanceIndicatorsOverallScoreController {
        
        private govProfile: GovernanceProfileController;
        public currentCompanyId: string;
        public indicatorsOverallScores: CompanyKeyGovernanceIssueOveralScoresDto;

        constructor(
            public $scope: Company.ICompanyBasedScope,
            public $rootScope: ng.IScope,
            public govService: GovernanceCompanyProfileService
            ) {
            this.govProfile = this.$scope['governancectrl']; //TODO if there is time refactor to be a base controller
            this.currentCompanyId = this.govProfile.company.id;
            this.init();
        }

        private init(): void {
            var ctx = this;
            ctx.$rootScope['loading'] = true;
            ctx.govService.getCompanyCgIssuesOverallScores(ctx.currentCompanyId).then(a => {
                ctx.indicatorsOverallScores = a;
                ctx.$rootScope['loading'] = false;
            }, e => {
                    console.log(e);
                    ctx.$rootScope['loading'] = false;
            });
        }
    }

    angular.module('Sustainalytics.Governance').controller('GovernanceIndicatorsOverallScoreController', ['$scope', '$rootScope', 'GovernanceCompanyProfileService', GovernanceIndicatorsOverallScoreController]);
}